using System;
using System.ComponentModel.Composition;
using System.Data.Services.Client;
using System.Linq;
using System.Windows;
using OrbitOne.CRMLyncInfoDashboard.CRM.OrganizationData;
using OrbitOne.CRMLyncInfoDashboard.CRM.WCF;

namespace OrbitOne.CRMLyncInfoDashboard.CRM.OData
{
    [Export(typeof(ICrmDataProvider))]
    public class CrmAccountDataProvider : CrmDataProvider<Account, AccountModel>, ICrmAccountDataProvider
    {
        

        [ImportingConstructor]
        public CrmAccountDataProvider(IPredicateBuilder predicateBuilder,
            ICrmAccountMetadataProvider crmAccountMetadataProvider,
             IClientScript clientScript)
            : base(predicateBuilder,
            crmAccountMetadataProvider,
            clientScript)
        {

        }
        
        protected override string LyncSearchFieldResourceName
        {
            get { return "AccountLyncSearchField"; }
        }

        protected override string[] GetSearchValues(Account entity)
        {
            return new[]{
                           (entity.Telephone1 ?? "").CleanupNonAlphanumeric(m_phoneNumberCleanup),
                           (entity.Telephone2 ?? "").CleanupNonAlphanumeric(m_phoneNumberCleanup),
                           (entity.EMailAddress1 ?? "")
                       };
        }
    }
}